DEFINITION MODULE InTerminal; (* ETHZ Modula2 Compiler 1985 *)

(* a collection of input routines, and string -> number conversions *)

FROM SYSTEM IMPORT WORD, ADDRESS;

EXPORT QUALIFIED ReadC, ReadI, ReadH, ReadAC, ReadAH, ReadCM, ReadAM,
                 ConvertToC, ConvertToI, ConvertToH,
                 ConvertToAC, ConvertToAH,
                 ConvertToCM, ConvertToAM,
                 InDone, InEmpty, InEsc, InNoNum, InTooBig;

VAR InDone:   BOOLEAN;  (* not empty, not ESC, not non-numeric, not too big *)
    InEmpty:  BOOLEAN;  (* why not done:                        *)
    InEsc:    BOOLEAN;  (* reading was terminated by escape char *)
    InNoNum:  BOOLEAN;
    InTooBig: BOOLEAN;

PROCEDURE ReadC(VAR c: CARDINAL);
PROCEDURE ReadI(VAR i: INTEGER);
PROCEDURE ReadH(VAR c: WORD);
PROCEDURE ReadAC(VAR a: ADDRESS);
PROCEDURE ReadAH(VAR a: ADDRESS);

PROCEDURE ReadCM(VAR c: WORD);       (* read cardinal in mixed decimal/hex base*)
PROCEDURE ReadAM(VAR c: ADDRESS);    (* read address in mixed decimal/hex base*)
                                     (* with a suffix H: base is hexadecimal  *)
                                     (* without a suffix H: base is decimal *)

(* note: use ReadAgain to store a digit read in advance                *)
(* note: use ReadAgain+ Read(ch) to find the last char read (e.g.ESC)   *)

PROCEDURE ConvertToC(VAR s: ARRAY OF CHAR; VAR c: CARDINAL);
PROCEDURE ConvertToI(VAR s: ARRAY OF CHAR; VAR i: INTEGER);
PROCEDURE ConvertToH(VAR s: ARRAY OF CHAR; VAR w: WORD);
PROCEDURE ConvertToAC(VAR s: ARRAY OF CHAR; VAR a: ADDRESS);
PROCEDURE ConvertToAH(VAR s: ARRAY OF CHAR; VAR a: ADDRESS);

PROCEDURE ConvertToCM(VAR s: ARRAY OF CHAR; VAR w: WORD);  (* convert cardinal mixed *)
PROCEDURE ConvertToAM(VAR s: ARRAY OF CHAR; VAR a: ADDRESS); (* convert address mixed*)

END InTerminal.
